<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" type="" href="../../sq/css/public.css">
    <link rel="stylesheet" type="" href="http://at.alicdn.com/t/font_5ufdxzeyp919k9.css">
    <link rel="stylesheet" type="" href="../../sq/css/administrate.css">
    <title>店铺管理</title>
</head>
<body>
<div id="header">
    <span class="left" onclick="window.history.go(-1)"><i class="icon iconfont icon-fanhui"></i></span>
    <p>店铺信息</p>
</div>
    <div class="pic">
    </div>
    <div class="shop_name">

    </div>
    <div class="explain">
        每让利300元即可得到一个金币,享受让利销售(同时享受其他优惠),消费回返的商家将优先排序
    </div>
    <div class="end">
        提交
    </div>
<script type="text/html" id="top_header">
    <% if(store_info['store_banner']){ %>
        <img src="<%= store_info['store_banner'] %>" alt="">
    <% }else{ %>
       <img src="../../images/dianpu.png" alt="">
    <% } %>
</script>
<script type="text/html" id="store_info">
    <% if(store_info['store_map']) { %>
    <input type="hidden" id="map" value="<%= store_info['store_map']['baidu_lat'] %>">
    <input type="hidden" id="lat" value="<%= store_info['store_map']['baidu_lat'] %>">
    <input type="hidden" id="lng" value="<%= store_info['store_map']['baidu_lng'] %>">
    <input type="hidden" id="pro" value="<%= store_info['store_map']['baidu_province'] %>">
    <input type="hidden" id="city" value="<%= store_info['store_map']['baidu_city'] %>">
    <input type="hidden" id="dis" value="<%= store_info['store_map']['baidu_district'] %>">
    <input type="hidden" id="street" value="<%= store_info['store_map']['baidu_street'] %>">
    <% } %>
    <div>
    店铺名称<input type="text" id="store_name" value="<%= store_info['store_name'] %>">
            </div>
            <div>
            店铺类别<input type="text" value="商圈">
            </div>
            <div>
            营业时间<input type="text" id="store_time" value="<%= store_info['store_time'] %>">
            </div>
            <div>
            联系电话<input type="tel" id="store_tel" <% if(store_info['store_tel']!=0) { %> value="<%= store_info['store_tel'] %>"<% }else{ %> placeholder="暂未填写电话"<%}%>>
            </div>
            <div style="height:20px;background-color: #f0eff5;"></div>
            <div>
            店铺地址<input type="text" id="store_address" <% if(store_info['store_map']) { %> value="<%= store_info['store_map']['address_info'] %>"<% }else{ %> placeholder="暂未填写地址"<%}%>">
            </div>
            <div>
            让利折扣<input type="text" readonly value="20%">
            </div>
</script>
<script type="text/javascript" src="../../js/config.js"></script>
<script type="text/javascript" src="../../js/zepto.min.js"></script>
<script type="text/javascript" src="../../js/template.js"></script>
<script type="text/javascript" src="../../js/startmove.js"></script>
<script type="text/javascript" src="../../js/simple-plugin.js"></script>
<script type="text/javascript" src="../../js/common.js"></script>
<script>

    $(function() {
        var key = getCookie('key');
        var storeid = getCookie('sqstoreid');
        if (!key || !storeid) {
            window.location.href = '/sq/login.html';
        }

        // 请求店铺信息
        $.ajax({
            type: 'get',
            url: ApiUrl + "/index.php?act=store&op=getSqStoreInfo",
            data: {key: key, sqstore_id: storeid},
            dataType: "json",
            success: function (data) {
                var store = template.render('top_header', data.datas);
                $(".pic").html(store);
                var store_info = template.render('store_info', data.datas);
                $(".shop_name").html(store_info);
            }
        })

        $(".end").on('click',function(){
            var name = $("#store_name").val();
            var time = $("#store_time").val();
            var address = $("#store_address").val()=='暂未填写地址'?'':$("#store_address").val();
            var tel = $("#store_tel").val()=='暂未填写电话'?'':$("#store_tel").val();
            var map = $("map").val();
            var pro = $("pro").val();
            var city = $("city").val();
            var dis = $("dis").val();
            var street = $("street").val();
            var lat = $("lat").val();
            var lng = $("lng").val();
            if(name==''){
                    creatLayout("请填写详细信息");
            }
            $.sDialog({
                skin:"red",
                content:"确认要提交信息吗？",
                okBtn:true,
                cancelBtn:true,
                okFn: toSubmit, //点击确定按钮执行的函数
            });

            function toSubmit(){
                $.ajax({
                    type:'POST',
                    url:ApiUrl+"/index.php?act=store&op=saveSqStore",
                    data:{key:key,name:name,time:time,address:address,tel:tel,map_id:map,lat:lat,lng:lng,pro:pro,city:city,dis:dis,street:street},
                    dataType:"json",
                    success:function(data){
                          creatLayout(data.datas.msg)
                    }
                })
            }
        });
    });
        function calcRem() {
        var http = document.getElementsByTagName("html")[0];
        var w = document.documentElement.clientWidth;
        http.style.fontSize = w / 32 + "px";
       }
    calcRem();
    window.onresize = function() {
        calcRem();
    };
</script>
</body>
</html>